
* main empirical tauctionx do file

/*
* version
version 17

* required packages
ssc install ivreg2
ssc install reghdfe
ssc install ivreghdfe
ssc install winsor2

ssc install gtools
net install binscatter2, from("https://raw.githubusercontent.com/mdroste/stata-binscatter2/master/")

*/

********************************************************************************
********************************************************************************
* load ado files
run calc_nss_yield.ado
run run_ph_regression.ado
run run_ph_alt_regression.ado
run plot_ph_regression.ado
run plot_ph_alt_regression.ado


* plotting options
set scheme lean_uncluttered

********************************************************************************
********************************************************************************
* step0: basic cleaning and merging
n di _dup(50) "="
n di "cleaning"
n di _dup(50) "="

n run step0a_clean_auction_data

n run step0d_merge_auction_shocks

n run step0e_clean_crisis_indicators

graph drop _all


********************************************************************************
********************************************************************************
* step1: summary stats and plots
n di _dup(50) "="
n di "summary stats"
n di _dup(50) "="

n run step1a_auction_summary

n run step1b_shock_summary

n run step1c_auction_demand_regressions

graph drop _all


********************************************************************************
********************************************************************************
* step2: asset price shock regressions
n di _dup(50) "="
n di "asset price regressions"
n di _dup(50) "="

n run step2a_asset_price_regressions

n run step2b_asset_price_iv_regressions

* command line options: 1 to re-run intraday/daily/ffr rolling regressions
n run step2c_rolling_asset_price 1 1 1

n run step2d_inflexp_regressions

n run step2e_longdiff_regressions

graph drop _all


********************************************************************************
********************************************************************************
* step3: preferred habitat regression
n di _dup(50) "="
n di "preferred habitat regressions"
n di _dup(50) "="

* command line options: 1 to re-estimate PH regressions
n run step3a_ph_regression_baseline 1

n run step3b_ph_regression_robustness_cutoffs 1

n run step3c_ph_regression_robustness_crisis 1

n run step3d_ph_alt_regression_robustness_b2c 1

n run step3e_ph_asset_regression

graph drop _all


********************************************************************************
********************************************************************************
* step4: additional misc analysis
n di _dup(50) "="
n di "misc analysis"
n di _dup(50) "="

n run step4a_fed_balance_sheet

n run step4b_example_shock_plots

n run step4c_example_yield_curve_plots

n run step4d_plot_crisis_measures

n run step4e_prepare_model_data

graph drop _all



n di _dup(50) "="
n di "main_empirical finished"
n di _dup(50) "="

